package moonlander;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class MoonKeyListener implements KeyListener {
	private double fuel=100;
	private boolean keyup= false;
	
	
	public MoonKeyListener(){}
	public void keyPressed(KeyEvent e) {
		int code = e.getKeyCode();
		if(code == KeyEvent.VK_RIGHT || code == KeyEvent.VK_KP_RIGHT) {
			int x = LanderCanvas.getXPos();
			LanderCanvas.setXPos(x+5);
			setKeyup(false);
		} else if(code == KeyEvent.VK_LEFT || code == KeyEvent.VK_KP_LEFT) {
			int x = LanderCanvas.getXPos();
			LanderCanvas.setXPos(x-5);
			setKeyup(false);
		
		} else if(code == KeyEvent.VK_UP || code == KeyEvent.VK_KP_UP) {
			if(getFuel()>0){
			int y = LanderCanvas.getYPos();
			LanderCanvas.setYPos(y-4);//((int)(y*0.97));
			setFuel(getFuel() - 1);
			LanderFrame.status.setText("Fuel Remaining: "+getFuel() + " litres");
			LanderCanvas.boost =true;
	}
		}

	}

	@Override
	public void keyReleased(KeyEvent e) {
		
	}

	@Override
	public void keyTyped(KeyEvent e) {
		

	}
	
	public boolean boosting(){
		return keyup;
	}

	double getFuel() {
		return fuel;
	}

	void setFuel(double d) {
		this.fuel = d;
	}
	public void setKeyup(boolean keyup) {
		this.keyup = keyup;
	}
	public boolean isKeyup() {
		return keyup;
	}

}
